﻿<Window x:Class="Tagomatique.View.SearchWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        
        xmlns:conv="clr-namespace:Tagomatique.View.Converters"
        xmlns:Ressources="clr-namespace:Tagomatique.Resources;assembly=Tagomatique.Resources"
        
        Title="SearchWindow"
        Height="350"
        Width="860"
        WindowStartupLocation="CenterOwner">
    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="*" />
            <RowDefinition Height="80" />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>

        <UniformGrid Grid.Row="0" Rows="1">
            <Button Margin="0,0,4,0" Content="{x:Static Ressources:Messages.AjouterMedia}" Command="{Binding AjouterFichierCommand}" />
                <Button Margin="4,0,4,0" Content="{x:Static Ressources:Messages.AjouterMediaRelatif}" Command="{Binding AjouterFichierRelatifCommand}" />
            <Button Margin="4,0,4,0" Content="{x:Static Ressources:Messages.AjouterDossier}" Command="{Binding AjouterDossierCommand}" />
            <Button Margin="4,0,0,0" Content="{x:Static Ressources:Messages.AjouterDossierRelatif}" Command="{Binding AjouterDossierRelatifCommand}" />
        </UniformGrid>

        <DataGrid Grid.Row="1"  Margin="0,8,0,8"
                  AutoGenerateColumns="False"
                  ItemsSource="{Binding Medias, Mode=OneWay}">
            <DataGrid.Resources>
                <conv:BitmapConverter x:Key="convBitmap" />
            </DataGrid.Resources>
            <DataGrid.Columns>
                <DataGridTemplateColumn Width="15" CanUserResize="False" CanUserReorder="False">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Image x:Name="pictOK" Source="{Binding Source=OK, Converter={StaticResource convBitmap}}" />
                                <Image x:Name="pictError" Source="{Binding Source=Error, Converter={StaticResource convBitmap}}" />
                            </Grid>
                            
                            <DataTemplate.Triggers>
                                <DataTrigger Binding="{Binding Path=IsValid}" Value="True">
                                    <Setter TargetName="pictOK" Property="Visibility" Value="Visible" />
                                    <Setter TargetName="pictError" Property="Visibility" Value="Hidden" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                                    <Setter TargetName="pictOK" Property="Visibility" Value="Hidden" />
                                    <Setter TargetName="pictError" Property="Visibility" Value="Visible" />
                                </DataTrigger>
                            </DataTemplate.Triggers>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Nom" Binding="{Binding Nom}" />
                <DataGridTextColumn Header="Dossier" Binding="{Binding RelativeURL}" />
            </DataGrid.Columns>
            <DataGrid.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander>
                                            <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Path=ItemCount}" Margin="8,0,4,0"/>
                                                    <TextBlock Text="Item(s) dans le dossier "/>
                                                    <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
                                                </StackPanel>
                                            </Expander.Header>
                                            <ItemsPresenter />
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>
        </DataGrid>

        <UniformGrid Grid.Row="2" Rows="2" Columns="4" Margin="0,0,0,8">
            <TextBlock Text="{Binding NombreMediaText}" />
            <TextBlock Text="{Binding NombrePhotoText}" />
            <TextBlock Text="{Binding NombreMusiqueText}" />
            <TextBlock Text="{Binding NombreVideoText}" />

            <TextBlock Text="{Binding NombreMediaValideText}" />
            <TextBlock Text="{Binding NombreMediaInvalideText}" />
        </UniformGrid>

        <UniformGrid Grid.Row="3" Rows="1" Columns="4">
            <Button Content="{x:Static Ressources:Messages.RescannerDossierDejaAjouter}" Margin="0,0,4,0" />
            <Grid Margin="4,0,4,0" />

            <Button Content="{x:Static Ressources:Messages.Valider}" Margin="4,0,4,0" />
            <Button Content="{x:Static Ressources:Messages.Annuler}" Margin="4,0,0,0" />
        </UniformGrid>
    </Grid>
</Window>